{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b4e06a8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from torch import nn,optim\n",
    "from torch.autograd import Variable\n",
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5deb7be2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiwAAAGdCAYAAAAxCSikAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA9jElEQVR4nO3de3RU9b3//9ckkASBxABfMglGgrRVETFHLhEFbysKp/y8tItfES+h9ByteGlrLAL1QOBgm4Qvp6UVCqvpxZ6iYnuOHLG6IhqMPdogPUSqCEUbEVpkgoBkMAiJM/v7B2cCSeay92Que888H2vNH0z27PnsbZb7nc/n/X5/XIZhGAIAALCxjGQPAAAAIBICFgAAYHsELAAAwPYIWAAAgO0RsAAAANsjYAEAALZHwAIAAGyPgAUAANhev2QPIBb8fr8++ugjDR48WC6XK9nDAQAAJhiGoePHj6uoqEgZGeHnUFIiYPnoo49UXFyc7GEAAIAo/O1vf9N5550X9piUCFgGDx4s6fQF5+bmJnk0AADADK/Xq+Li4q7neDgpEbAEloFyc3MJWAAAcBgz6Rwk3QIAANsjYAEAALZHwAIAAGyPgAUAANgeAQsAALA9AhYAAGB7BCwAAMD2CFgAAIDtpUTjOAAAEJ7Pb2jb3qM6dPykhg/O0aRRQ5SZ4Zz99whYAABIcfU7D2rZ87t0sO1k13uFeTmqummMpo8tTOLIzGNJCACAFFa/86DmrW/uFqxIkqftpOatb1b9zoNJGpk1BCwAAKQon9/Qsud3yQjys8B7y57fJZ8/2BH2QsACAECK2rb3aK+ZlbMZkg62ndS2vUcTN6goEbAAAJCiDh0PH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DkvHDH/7QeOutt4x9+/YZhmEYCxcuNO66666u4wNlzfPnzzd2795trFmzhrLmaD3++OPG+eefb2RlZRmTJk0ytm7d2vWza665xpgzZ06343/7298aX/rSl4ysrCzjkksuMV544YUEj9jZrNzvkSNHGpJ6vaqqqhI/cAez+jt+NgIW66ze7z/+8Y9GWVmZkZ2dbVxwwQXG97//fePzzz9P8Kidzco97+zsNJYuXWqMHj3ayMnJMYqLi4377rvP+OSTTxI/cAd69dVXg/5/OXCP58yZY1xzzTW9PlNaWmpkZWUZF1xwgfGrX/2qz+NwGQbzYQAAwN7SKocFAAA4EwELAACwPQIWAABgewQsAADA9ghYAACA7RGwAAAA2yNgAQAAtkfAAgAAbI+ABQAA2B4BCwAAsD0CFgAAYHsELAAAwPb+H1aOtfLu/HoJAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_data=np.random.rand(100)\n",
    "noise=np.random.normal(0,0.01,x_data.shape)\n",
    "y_data=x_data*0.1+0.2+noise\n",
    "plt.scatter(x_data,y_data)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "806e9472",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.04807755],\n",
       "       [0.46874423],\n",
       "       [0.19075419],\n",
       "       [0.87349717],\n",
       "       [0.73036953],\n",
       "       [0.21873036],\n",
       "       [0.36687767],\n",
       "       [0.97003908],\n",
       "       [0.46792138],\n",
       "       [0.11156837],\n",
       "       [0.06090553],\n",
       "       [0.86446851],\n",
       "       [0.25132439],\n",
       "       [0.03109824],\n",
       "       [0.34049006],\n",
       "       [0.10038915],\n",
       "       [0.79693118],\n",
       "       [0.681031  ],\n",
       "       [0.87767823],\n",
       "       [0.02265633],\n",
       "       [0.04123734],\n",
       "       [0.0094291 ],\n",
       "       [0.08678855],\n",
       "       [0.48660708],\n",
       "       [0.65590314],\n",
       "       [0.83452184],\n",
       "       [0.28388374],\n",
       "       [0.27028414],\n",
       "       [0.64578257],\n",
       "       [0.93737112],\n",
       "       [0.69577404],\n",
       "       [0.14765594],\n",
       "       [0.31240134],\n",
       "       [0.58135534],\n",
       "       [0.0826082 ],\n",
       "       [0.44047417],\n",
       "       [0.79402563],\n",
       "       [0.91123404],\n",
       "       [0.75816285],\n",
       "       [0.22858582],\n",
       "       [0.48728012],\n",
       "       [0.57892813],\n",
       "       [0.59072078],\n",
       "       [0.34762481],\n",
       "       [0.8774695 ],\n",
       "       [0.19645581],\n",
       "       [0.94389072],\n",
       "       [0.6727042 ],\n",
       "       [0.31399472],\n",
       "       [0.29520239],\n",
       "       [0.32854443],\n",
       "       [0.48231174],\n",
       "       [0.5861206 ],\n",
       "       [0.91921784],\n",
       "       [0.8106124 ],\n",
       "       [0.37570512],\n",
       "       [0.46726065],\n",
       "       [0.36259492],\n",
       "       [0.9843625 ],\n",
       "       [0.145931  ],\n",
       "       [0.03651424],\n",
       "       [0.98438805],\n",
       "       [0.65456828],\n",
       "       [0.13249516],\n",
       "       [0.78281667],\n",
       "       [0.17142468],\n",
       "       [0.80229762],\n",
       "       [0.37029173],\n",
       "       [0.41033245],\n",
       "       [0.27252533],\n",
       "       [0.12700126],\n",
       "       [0.90535497],\n",
       "       [0.11671209],\n",
       "       [0.39487378],\n",
       "       [0.37314893],\n",
       "       [0.08993677],\n",
       "       [0.75518   ],\n",
       "       [0.43709941],\n",
       "       [0.2685399 ],\n",
       "       [0.02025873],\n",
       "       [0.96604749],\n",
       "       [0.11900406],\n",
       "       [0.42932805],\n",
       "       [0.95360479],\n",
       "       [0.15242682],\n",
       "       [0.44917177],\n",
       "       [0.80470915],\n",
       "       [0.0891939 ],\n",
       "       [0.07113913],\n",
       "       [0.04654869],\n",
       "       [0.03544657],\n",
       "       [0.82603517],\n",
       "       [0.08968685],\n",
       "       [0.6916761 ],\n",
       "       [0.75658574],\n",
       "       [0.29955864],\n",
       "       [0.94321405],\n",
       "       [0.39775661],\n",
       "       [0.35672555],\n",
       "       [0.73493822]])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_data=x_data.reshape(-1,1)\n",
    "y_data=y_data.reshape(-1,1)\n",
    "x_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "b4b876fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.20655977],\n",
       "       [0.25093466],\n",
       "       [0.20751255],\n",
       "       [0.28936937],\n",
       "       [0.28326111],\n",
       "       [0.22439052],\n",
       "       [0.24959356],\n",
       "       [0.29230984],\n",
       "       [0.24575399],\n",
       "       [0.21678798],\n",
       "       [0.20847209],\n",
       "       [0.29751923],\n",
       "       [0.22925712],\n",
       "       [0.20472394],\n",
       "       [0.22774497],\n",
       "       [0.20653776],\n",
       "       [0.27017429],\n",
       "       [0.24977199],\n",
       "       [0.28523636],\n",
       "       [0.20652782],\n",
       "       [0.2146559 ],\n",
       "       [0.19302356],\n",
       "       [0.2052623 ],\n",
       "       [0.27308672],\n",
       "       [0.26491742],\n",
       "       [0.27954203],\n",
       "       [0.2225502 ],\n",
       "       [0.22680997],\n",
       "       [0.25823999],\n",
       "       [0.29518239],\n",
       "       [0.27670347],\n",
       "       [0.20835565],\n",
       "       [0.22540962],\n",
       "       [0.25453359],\n",
       "       [0.21421036],\n",
       "       [0.23622762],\n",
       "       [0.27763662],\n",
       "       [0.30399135],\n",
       "       [0.27840374],\n",
       "       [0.22766592],\n",
       "       [0.24186178],\n",
       "       [0.26184661],\n",
       "       [0.24024676],\n",
       "       [0.2361762 ],\n",
       "       [0.290787  ],\n",
       "       [0.21152244],\n",
       "       [0.29267919],\n",
       "       [0.2760044 ],\n",
       "       [0.22739691],\n",
       "       [0.22328238],\n",
       "       [0.21386011],\n",
       "       [0.23844302],\n",
       "       [0.25831867],\n",
       "       [0.294462  ],\n",
       "       [0.28487551],\n",
       "       [0.24976438],\n",
       "       [0.25082287],\n",
       "       [0.2467414 ],\n",
       "       [0.30141113],\n",
       "       [0.21410856],\n",
       "       [0.21004104],\n",
       "       [0.29464596],\n",
       "       [0.2727916 ],\n",
       "       [0.21259308],\n",
       "       [0.27884538],\n",
       "       [0.21517828],\n",
       "       [0.28304962],\n",
       "       [0.22593031],\n",
       "       [0.22522742],\n",
       "       [0.24403523],\n",
       "       [0.21488687],\n",
       "       [0.30576664],\n",
       "       [0.2016769 ],\n",
       "       [0.24305784],\n",
       "       [0.23971291],\n",
       "       [0.20761127],\n",
       "       [0.25393767],\n",
       "       [0.26539112],\n",
       "       [0.20821196],\n",
       "       [0.21720621],\n",
       "       [0.29987135],\n",
       "       [0.2003734 ],\n",
       "       [0.23368773],\n",
       "       [0.30808164],\n",
       "       [0.21801802],\n",
       "       [0.24990896],\n",
       "       [0.26897748],\n",
       "       [0.20559535],\n",
       "       [0.19946208],\n",
       "       [0.20656141],\n",
       "       [0.20333601],\n",
       "       [0.28413697],\n",
       "       [0.21643794],\n",
       "       [0.28732199],\n",
       "       [0.27348077],\n",
       "       [0.23606897],\n",
       "       [0.29510776],\n",
       "       [0.24393855],\n",
       "       [0.22933255],\n",
       "       [0.28074051]])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "347c7104",
   "metadata": {},
   "outputs": [],
   "source": [
    "x_data=torch.FloatTensor(x_data)\n",
    "y_data=torch.FloatTensor(y_data)\n",
    "inputs=Variable(x_data)\n",
    "target=Variable(y_data)\n",
    "#以上把numpy变成了tensor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "054c8261",
   "metadata": {},
   "outputs": [],
   "source": [
    "#构建神经网络模型\n",
    "#一般把需要训练的参数放在初始化层中\n",
    "class  LinearRegression(nn.Module):\n",
    "    #这个用来定义结构\n",
    "    def _init_(self):\n",
    "        super(LinearRegression,self)._init_()\n",
    "        self.fc=nn.Linear(1,1)\n",
    "        #这个用来计算\n",
    "    def forward(self,x):\n",
    "        out=self.fc(x)\n",
    "        return out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "14fafa30",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "optimizer got an empty parameter list",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[21], line 6\u001b[0m\n\u001b[0;32m      4\u001b[0m mse_loss\u001b[38;5;241m=\u001b[39mnn\u001b[38;5;241m.\u001b[39mMSELoss()\n\u001b[0;32m      5\u001b[0m \u001b[38;5;66;03m#定义优化器\u001b[39;00m\n\u001b[1;32m----> 6\u001b[0m optimizer\u001b[38;5;241m=\u001b[39m\u001b[43moptim\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mSGD\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparameters\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43mlr\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m0.1\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mD:\\anaconda\\envs\\yzk\\lib\\site-packages\\torch\\optim\\sgd.py:56\u001b[0m, in \u001b[0;36mSGD.__init__\u001b[1;34m(self, params, lr, momentum, dampening, weight_decay, nesterov, maximize, foreach, differentiable, fused)\u001b[0m\n\u001b[0;32m     54\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m nesterov \u001b[38;5;129;01mand\u001b[39;00m (momentum \u001b[38;5;241m<\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m dampening \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m0\u001b[39m):\n\u001b[0;32m     55\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNesterov momentum requires a momentum and zero dampening\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m---> 56\u001b[0m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__init__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdefaults\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m     58\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m fused:\n\u001b[0;32m     59\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_step_supports_amp_scaling \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n",
      "File \u001b[1;32mD:\\anaconda\\envs\\yzk\\lib\\site-packages\\torch\\optim\\optimizer.py:362\u001b[0m, in \u001b[0;36mOptimizer.__init__\u001b[1;34m(self, params, defaults)\u001b[0m\n\u001b[0;32m    360\u001b[0m param_groups \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(params)\n\u001b[0;32m    361\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(param_groups) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m--> 362\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124moptimizer got an empty parameter list\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m    363\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(param_groups[\u001b[38;5;241m0\u001b[39m], \u001b[38;5;28mdict\u001b[39m):\n\u001b[0;32m    364\u001b[0m     param_groups \u001b[38;5;241m=\u001b[39m [{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mparams\u001b[39m\u001b[38;5;124m\"\u001b[39m: param_groups}]\n",
      "\u001b[1;31mValueError\u001b[0m: optimizer got an empty parameter list"
     ]
    }
   ],
   "source": [
    "#定义模型\n",
    "model=LinearRegression()\n",
    "#定义代价函数\n",
    "mse_loss=nn.MSELoss()\n",
    "#定义优化器\n",
    "optimizer=optim.SGD(model.parameters(),lr=0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b1c3dbe9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:yzk] *",
   "language": "python",
   "name": "conda-env-yzk-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
